import request from '@/config/axios'

// 生产工单数据 VO
export interface ProductionWorkOrderVO {
  id: number // 主键ID
  workOrderNo: string // 工单号
  itemCode: string // 品号/物料编码
  productType: string // 产品类型
  unit: string // 单位
  wipCompletedQty: number // 在制品完成数
  wipScrappedQty: number // 在制品报废数
  defectiveQty: number // 不良数量
  reworkQty: number // 返工数
  salesOrderNo: string // 销售订单号
}

// 生产工单数据 API
export const ProductionWorkOrderApi = {
  // 查询生产工单数据分页
  getProductionWorkOrderPage: async (params: any) => {
    return await request.get({ url: `/server/production-work-order/page`, params })
  },

  // 查询生产工单数据详情
  getProductionWorkOrder: async (id: number) => {
    return await request.get({ url: `/server/production-work-order/get?id=` + id })
  },

  // 新增生产工单数据
  createProductionWorkOrder: async (data: ProductionWorkOrderVO) => {
    return await request.post({ url: `/server/production-work-order/create`, data })
  },

  // 修改生产工单数据
  updateProductionWorkOrder: async (data: ProductionWorkOrderVO) => {
    return await request.put({ url: `/server/production-work-order/update`, data })
  },

  // 删除生产工单数据
  deleteProductionWorkOrder: async (id: number) => {
    return await request.delete({ url: `/server/production-work-order/delete?id=` + id })
  },

  // 导出生产工单数据 Excel
  exportProductionWorkOrder: async (params) => {
    return await request.download({ url: `/server/production-work-order/export-excel`, params })
  },

  getList: async (params: any) => {
    return await request.get({ url: `/server/production-work-order/list`, params })
  }
}

